/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Reynusa
 */
public class TerimaBarang {

    private String KodeBarang;
    private String NamaBarang;
    private String JenisBarang;
    private int JumlahBarang;
    private double HargaBarang;
    private String KodeToko;
    private String Tgl_terima;
    private String Id_terima;

    public double getHargaBarang() {
        return HargaBarang;
    }

    public void setHargaBarang(double HargaBarang) {
        this.HargaBarang = HargaBarang;
    }

    public String getId_terima() {
        return Id_terima;
    }

    public void setId_terima(String Id_terima) {
        this.Id_terima = Id_terima;
    }

    public String getJenisBarang() {
        return JenisBarang;
    }

    public void setJenisBarang(String JenisBarang) {
        this.JenisBarang = JenisBarang;
    }

    public int getJumlahBarang() {
        return JumlahBarang;
    }

    public void setJumlahBarang(int JumlahBarang) {
        this.JumlahBarang = JumlahBarang;
    }

    public String getKodeBarang() {
        return KodeBarang;
    }

    public void setKodeBarang(String KodeBarang) {
        this.KodeBarang = KodeBarang;
    }

    public String getKodeToko() {
        return KodeToko;
    }

    public void setKodeToko(String KodeToko) {
        this.KodeToko = KodeToko;
    }

    public String getNamaBarang() {
        return NamaBarang;
    }

    public void setNamaBarang(String NamaBarang) {
        this.NamaBarang = NamaBarang;
    }

    public String getTgl_terima() {
        return Tgl_terima;
    }

    public void setTgl_terima(String Tgl_terima) {
        this.Tgl_terima = Tgl_terima;
    }

    public TerimaBarang() {
    }

    public List lihatterima(String idterima, String tgl_terima) throws SQLException {
        List terima = new ArrayList();
      Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs125314075", "mhs125314075");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "reynusa", "reynusa");
        String retrieveQuery = "select * from terimabarang where idterima='" + idterima + "' and tgl_terima='" + tgl_terima + "'";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(retrieveQuery);
        while (rs.next()) {
            TerimaBarang terimax = new TerimaBarang();
            terimax.setKodeToko(rs.getString("kodetoko"));
            terimax.setKodeBarang(rs.getString("kodebarang"));
            terimax.setNamaBarang(rs.getString("namabarang"));
            terimax.setJenisBarang(rs.getString("jenisbarang"));
            terimax.setHargaBarang(rs.getDouble("hargabarang"));
            terimax.setJumlahBarang(rs.getInt("jumlahbarang"));
            terimax.setId_terima(rs.getString("idterima"));
            terimax.setTgl_terima(rs.getString("tgl_terima"));
            terima.add(terimax);
        }
        conn.commit();
        return terima;
    }
}
